<template>
  <div id="unit" class="flex" >
    <criteria-paged :model="model" v-ref:paged>
      <criteria partial='criteria' @condition-changed='search' v-ref:cri>
        <div novalidate class="form-inline" partial>
          <div class="form-group">
            <label for="f_bank_name" class = "control-form">银行名称:</label>
            <v-select id="f_bank_name"
            v-model="model.f_bank_name"
            placeholder='银行名称'
            condition="f_bank_name= '{}' "
            :value.sync="model.f_bank_name"
            :options='$parent.$parent.bankname'
            close-on-select ></v-select>
          </div>
          <div class="form-group form-input-group">
            <label for="startDate" class="control-label">开始日期:</label>
            <datepicker id="startDate" placeholder="开始日期" width='100%'
              v-model="model.startDate"
              :value.sync="model.startDate"
              :disabled-days-of-Week="[]"
              condition="f_trade_date > '{} 00:00:00' "
              :format="'yyyy-MM-dd'"
              :show-reset-button="reset">
            </datepicker>
          </div>

          <div class="form-group form-input-group">
            <label for="endDate" class="control-label">结束日期:</label>
            <datepicker id="endDate" placeholder="结束日期" width='100%'
              v-model="model.endDate"
              :value.sync="model.endDate"
              condition="f_trade_date < '{} 23:59:59' "
              :disabled-days-of-Week="[]"
              :format="'yyyy-MM-dd'"
              :show-reset-button="reset">
            </datepicker>
          </div>
          <div class="form-group">
            <button class="btn btn-success width-80" @click="search()" v-el:cx>查询</button>
          </div>
        </div>
      </criteria>
      <data-grid :model="model" partial='list' v-ref:grid>
        <template partial='head'>
          <tr>
            <th>序号</th>
            <th>银行名</th>
            <th>数目</th>
            <th>总计气量</th>
            <th>总计金额</th>
          </tr>
        </template>
        <template partial='body'>
          <td style="text-align: center;">{{$index+1}}</td>
          <td v-if="model.rows[$index-1] && model.rows[$index-1].f_bank_name === row.f_bank_name"></td>
          <td v-else>{{row.f_bank_name}}</td>
          <td>{{row.id}}</td>
          <td>{{row.f_total_charge}}</td>
          <td>{{row.f_total_gasamount}}</td>
        </template>
      </data-grid>
  </criteria-paged>
 </div>
</template>
<script>
import { PagedList } from 'vue-client'
import AppData from '../../../../../stores/AppData'

export default {
  title: '汇总银行信息',
  data () {
    return {
      model: new PagedList('rs/sql/bankQuery', 20)
    }
  },
  props: [],
  ready () {
    this.model.search('1=1')
  },
  methods: {
    search () {
      this.model.search()
    }
  },
  computed: {
    bankname () {
      return [{label: '全部', value: ''}, ...AppData.getParam('银行名称')]
    },
    filiales () {
      return [{label: '全部', value: ''}, ...AppData.getParam('分公司')]
    }
  }
}
</script>
